package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.ArtificerMeans;
import com.stylefeng.guns.modular.system.service.IArtificerMeansService;

/**
 * 技师列表控制器
 *
 * @author fengshuonan
 * @Date 2019-05-19 23:32:58
 */
@Controller
@RequestMapping("/artificerMeans")
public class ArtificerMeansController extends BaseController {

    private String PREFIX = "/system/artificerMeans/";

    @Autowired
    private IArtificerMeansService artificerMeansService;

    /**
     * 跳转到技师列表首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "artificerMeans.html";
    }

    /**
     * 跳转到添加技师列表
     */
    @RequestMapping("/artificerMeans_add")
    public String artificerMeansAdd() {
        return PREFIX + "artificerMeans_add.html";
    }

    /**
     * 跳转到修改技师列表
     */
    @RequestMapping("/artificerMeans_update/{artificerMeansId}")
    public String artificerMeansUpdate(@PathVariable Integer artificerMeansId, Model model) {
        ArtificerMeans artificerMeans = artificerMeansService.selectById(artificerMeansId);
        model.addAttribute("item",artificerMeans);
        LogObjectHolder.me().set(artificerMeans);
        return PREFIX + "artificerMeans_edit.html";
    }

    /**
     * 获取技师列表列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return artificerMeansService.selectList(null);
    }

    /**
     * 新增技师列表
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(ArtificerMeans artificerMeans) {
        artificerMeansService.insert(artificerMeans);
        return SUCCESS_TIP;
    }

    /**
     * 删除技师列表
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer artificerMeansId) {
        artificerMeansService.deleteById(artificerMeansId);
        return SUCCESS_TIP;
    }

    /**
     * 修改技师列表
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(ArtificerMeans artificerMeans) {
        artificerMeansService.updateById(artificerMeans);
        return SUCCESS_TIP;
    }

    /**
     * 技师列表详情
     */
    @RequestMapping(value = "/detail/{artificerMeansId}")
    @ResponseBody
    public Object detail(@PathVariable("artificerMeansId") Integer artificerMeansId) {
        return artificerMeansService.selectById(artificerMeansId);
    }
}
